package com.itheima.controller;

import com.itheima.pojo.OperateLog;
import com.itheima.pojo.PageResult;
import com.itheima.pojo.Result;
import com.itheima.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LogController {
    @Autowired
    private LogService logService;
    /**
     * 日志信息的分页查询
     * */
    @GetMapping("/log/page")
    public Result queryLogs(@RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "10")Integer pageSize){
        //1、接收请求参数
        log.info("分页查询请求参数：{},{}", page, pageSize);

        //2、调用业务层功能方法
        PageResult<OperateLog> pageResult = logService.queryAllLogs(page, pageSize);

        //3、将查询结果封装成Result对象并返回
        return Result.success(pageResult);
    }
}
